<template>
  <div>
    <el-menu
      default-active="2"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b">
      <sidebar-item v-for="(route,index) in routes" :key="index" :item="route" :base-path="route.path"/>
    </el-menu>
  </div>
</template>
<script>
  import SidebarItem from './SidebarItem'
  export default {
    name:'Slidebar',
    components: {
      SidebarItem
    },
    computed:{
      routes() {
        return this.$router.options.routes
      }
    },
    created(){
      console.log(this.routes);
    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      }
    }
  }
</script>